import {req_delete, req_get, req_post, req_put} from "@/request/cssdrequest";
import {R} from "@/type/dto/R";
import {RP} from "@/type/dto/RP";
import {TrainingLessonsInfoVO} from "@/type/vo/TrainingLessonsInfoVO";
import {TrainingUserInfoVO} from "@/type/vo/TrainingUserInfoVO";
import {DataBankInfoVO} from "@/type/vo/DataBankInfoVO";

// String dataName, String creatorName,
//     Date startDate, Date endDate,
//     Integer page, Integer limit
export async function api_listDataBank(dataName: string | null,
                                       startDate: string,
                                       creatorName: string,
                                       endDate: string,
                                       trainingTeacher: string,
                                       page: number,
                                       limit: number) {
    const data = await req_get('/databank', {
        dataName,
        creatorName,
        startDate,
        endDate,
        trainingTeacher,
        page,
        limit
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<RP<DataBankInfoVO>>;
}

export async function api_addDataBank(dataBank: DataBankInfoVO
) {

    const data = await req_post('/databank', dataBank);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

export async function api_getDataBankById(id:string) {
    const data = await req_get('/databank/id', {
        id
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<DataBankInfoVO>;
}

export async function api_updateTrain(dataBank: DataBankInfoVO
) {

    const data = await req_put('/databank', dataBank);
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}

export async function api_deleteTrain(id: string
) {

    const data = await req_delete('/databank', {

        id
    });
    //转成我要的json
    console.log('data:', data);
    return JSON.parse(data) as R<string>;
}